/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

/**
 *
 * @author chapmand
 */
public enum RepetitionType {
    NONE(0),
    YEARLY(1),
    QUARTERLY(2),
    MONTHLY(3),
    WEEKLY(4),
    DAILY(5);
    
    private int type;

    RepetitionType(final int type) {
        this.type = type;
    }

    public int getType() {
        return type;
    }

    public static RepetitionType getType(final String type) {
        return getType(Integer.parseInt(type));
    }
    
    public static RepetitionType getType(final int type) {
        switch (type) {
        case 0:
            return NONE;
        case 1:
            return YEARLY;
        case 2:
            return QUARTERLY;
        case 3:
            return MONTHLY;
        case 4:
            return WEEKLY;
        case 5:
            return DAILY;
        default:
            throw new EnumConstantNotPresentException(RepetitionType.class, String.valueOf(type));
        }
    }
    
    public static RepetitionType getTypeByName(final String str) {
        if(str.equals("YEARLY")){
            return YEARLY;
        } else if(str.equals("QUARTERLY")){
            return QUARTERLY;
        } else if(str.equals("MONTHLY")){
            return MONTHLY;
        } else if(str.equals("WEEKLY")){
            return WEEKLY;
        } else if(str.equals("DAILY")){
            return DAILY;
        } else if(str.equals("NONE")){
            return NONE;
        } else {
            return YEARLY;
        }
    }
}
